package chances.epg.ui.taglib.html;

import javax.servlet.jsp.JspException;

import org.apache.commons.lang.StringUtils;

import chances.epg.commons.utils.TextUtils;


/**
 * 多行文本的处理.
 * @author Elysium
 *
 */
public class MultiTextTag extends TextTag {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 7012997719518487375L;
	
	private int interval;//行间隔
	private int rows;//最大行数
	
	private String[] lines;
	
	@Override
    public void release() {
        super.release();
        lines = null;
    }
	
	@Override
    public int doEndTag() throws JspException {
        if (this.getBodyContent() != null) {
            text = this.getBodyContent().getString();
        }
        handleText();
        return super.doEndTag();
    }

    public void handleText() {
    	if(StringUtils.isBlank(text)){
    		return;
    	}
    	
    	//去前缀
        if(StringUtils.isNotBlank(this.prefix)){
        	text = StringUtils.removeStart(text, this.prefix);
        }
    	
        String content =TextUtils.filterHtmlTag(text,false);
        lines = TextUtils.getPageStrings(content, length, rows, false, DOT);
    }

	public int getInterval() {
		return interval;
	}

	public void setInterval(int interval) {
		this.interval = interval;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	public String[] getLines() {
		return lines;
	}

	public void setLines(String[] lines) {
		this.lines = lines;
	}
}
